<template>
	<!-- 问题列表 -->
	<view class="questionList">
		<view class="userTitle flex box-sizing  space-between items-center">
			<view class="box-sizing paddingLeft-30" style="width: 120rpx;">
				<u-icon @click="uni.navigateBack()" name="arrow-left" :size="25"></u-icon>
			</view>
			<view style="flex: 1;padding-left: calc(10rpx);"
				class=" flex box-sizing  flex-center items-center height-full">
				<view class="fontSize-30 weight-700 marginRight-10">
					{{title}}
				</view>
			</view>
			<view class="right box-sizing paddingRight-30">
				<view @click="$u.throttle(navigateTo('addQuestion'), 500)"
					class="submit flex flex-center items-center fontSize-27 color-white">
					提问
				</view>
			</view>
		</view>
		<view class="crads">
			<view class="width-full height-90 colorBj-fff " style="border-bottom: 1rpx solid #ededed;">
				<u-tabs :current = "parseInt(param.type) - 1" :list="[{name:'所有问题'},{name:'我的问题'}]" lineWidth="30" :activeStyle = "{ color: '#ff6f26' }" lineColor="#ff6f26" @change="tabsChange"></u-tabs>
			</view>
			<scroll-view :refresher-triggered="triggered" scroll-y="true"
				class="swiperItem flex column items-center box-sizing" refresher-enabled
				@refresherrefresh="scrolltoupper()">
				<view v-for="(t, index) in list" :key="index" @click="navigateTo(`questionDetails?pid=${t.faq_id}`)"
					class="colorBj-fff items-center flex card box-sizing padding-30 space-between fontSize-27 marginBottom-30" style="min-height: 200rpx;">
					<view class="flex column space-between height-full" style="width: 60%;">
						<span class="weight-700 marginBottom-20">
							{{t.name}}
						</span>
						<span class="fontSize-24 color-ededed marginBottom-20" style="color: #ababab;">
							{{t.adminuser&&t.adminuser.realname?t.adminuser.realname:''}}
						</span>
						<span class=" fontSize-22 width-120 text-center" style="display: inline-block; padding: 5rpx 10rpx; border-radius: 100rpx; background-color: #ededed;">
							{{t.faqtype_name}}
						</span>
					</view>
					<view class="fontSize-24 color-6d6d6d flex flex-end"  style="width: 40%;">
						{{t.create_time}}
					</view>
				</view>
				<view v-if="!list || list.length == 0" class="flex flex-center items-center"
					style="width: 100%;height: 100%;">
					<u-empty iconSize="60px" mode="search"></u-empty>
				</view>
				
			</scroll-view>
			</view>
		</view>
</template>

<script>
export default {
	data() {
		return {
			triggered: false,
			list: [],
			param:{
				type:1
			},
			title:''
			

		};
	},
	onLoad(op) {
		this.param['faq_type'] = op.faq_type
		this.title = op.title||''
		this.getList()
	},
	methods: {
		getList() {
			uni.showLoading();
			this.list = []
			this.$first.index(this.param).then(res => {
				console.log(res, '*******');
				this.list = res.data
				this.triggered = false
				uni.hideLoading();
			}).catch(err => {
				uni.hideLoading();
			})
		},
		// 调整新增
		addFaq(){
			uni.navigateTo({
				url:'/pages/index/addQuestion'
			})
		},
		tabsChange(e){
			console.log(e,'bbbbbbbbb')
			if(this.param.type != parseInt(e.index)+1){
				this.param.type = parseInt(e.index)+1
				this.getList()
			}
		},
		scrolltoupper() {
			this.triggered = true
			this.getList()
		},
	}
}
</script>

<style lang="scss">
.questionList {
	height: 100vh;
	box-sizing: border-box;
	background-color: #F8F9FD;
	.userTitle {
		width: 100%;
		height: 120rpx;
		box-sizing: border-box;
		padding-top: var(--status-bar-height);
		background-color: #fff;
		border-bottom: 1rpx solid #ededed;
	}
	.submit {
		width: 120rpx;
		padding: 5rpx 0rpx;
		border-radius: 10rpx;
		border: 1rpx solid #fff;
		background-color: #ea9700a1;
	}
	.crads {
		width: 100%;

		// height: calc(100vh - 140rpx - 120rpx);
		// overflow-y: auto;
		
			.swiperItem {
				width: 100%;
				height: calc(100vh - 91rpx - 120rpx);
				// overflow-y: auto;
				display: flex;
				flex-direction: column;
				align-items: center;
			}

		.card {
			// margin: 0 auto 30rpx;
			// width: calc(100% - 60rpx);
			color: #333;
		}

		.color-f6ffff {
			background-color: #f6ffff;
		}

		.color-fff8f6 {
			background-color: #fff8f6;
		}
	}

}
</style>
